﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// BLL_tb_MidSoft_CheckupForm
	/// </summary>
	public partial class BLL_tb_MidSoft_CheckupForm
	{
		private readonly ChinaSoft.DAL.DAL_tb_MidSoft_CheckupForm dal=new ChinaSoft.DAL.DAL_tb_MidSoft_CheckupForm();
		public BLL_tb_MidSoft_CheckupForm()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int CheckupFormId)
		{
			return dal.Exists(CheckupFormId);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(ChinaSoft.Model.Model_tb_MidSoft_CheckupForm model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_tb_MidSoft_CheckupForm model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int CheckupFormId)
		{
			
			return dal.Delete(CheckupFormId);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string CheckupFormIdlist )
		{
			return dal.DeleteList(CheckupFormIdlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_CheckupForm GetModel(int CheckupFormId)
		{
			
			return dal.GetModel(CheckupFormId);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_CheckupForm GetModelByCache(int CheckupFormId)
		{
			
			string CacheKey = "Model_tb_MidSoft_CheckupFormModel-" + CheckupFormId;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(CheckupFormId);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_tb_MidSoft_CheckupForm)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_CheckupForm> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_CheckupForm> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_tb_MidSoft_CheckupForm> modelList = new List<ChinaSoft.Model.Model_tb_MidSoft_CheckupForm>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_tb_MidSoft_CheckupForm model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_tb_MidSoft_CheckupForm();
					if(dt.Rows[n]["CheckupFormId"]!=null && dt.Rows[n]["CheckupFormId"].ToString()!="")
					{
						model.CheckupFormId=int.Parse(dt.Rows[n]["CheckupFormId"].ToString());
					}
					if(dt.Rows[n]["ProjectInfoId"]!=null && dt.Rows[n]["ProjectInfoId"].ToString()!="")
					{
						model.ProjectInfoId=int.Parse(dt.Rows[n]["ProjectInfoId"].ToString());
					}
					if(dt.Rows[n]["CheckupType"]!=null && dt.Rows[n]["CheckupType"].ToString()!="")
					{
					model.CheckupType=dt.Rows[n]["CheckupType"].ToString();
					}
					if(dt.Rows[n]["CheckupNumber"]!=null && dt.Rows[n]["CheckupNumber"].ToString()!="")
					{
					model.CheckupNumber=dt.Rows[n]["CheckupNumber"].ToString();
					}
					if(dt.Rows[n]["CheckupDate"]!=null && dt.Rows[n]["CheckupDate"].ToString()!="")
					{
						model.CheckupDate=DateTime.Parse(dt.Rows[n]["CheckupDate"].ToString());
					}
					if(dt.Rows[n]["CheckupContent"]!=null && dt.Rows[n]["CheckupContent"].ToString()!="")
					{
					model.CheckupContent=dt.Rows[n]["CheckupContent"].ToString();
					}
					if(dt.Rows[n]["CreateTime"]!=null && dt.Rows[n]["CreateTime"].ToString()!="")
					{
						model.CreateTime=DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
					}
					if(dt.Rows[n]["CreateUserId"]!=null && dt.Rows[n]["CreateUserId"].ToString()!="")
					{
						model.CreateUserId=int.Parse(dt.Rows[n]["CreateUserId"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

